export const storageTools = {
  setLocalStorage(key: string, value: any) {
    if (!localStorage) {
      return
    }
    if (key != null && value != null) {
      localStorage.setItem(key, value)
    }
  },
  getLocalStorage(key: string) {
    if (!localStorage) {
      return null
    }
    if (key == null) {
      return null
    }
    return localStorage.getItem(key)
  },
  setJSONLocalStorage(key: string, jsonValue: any) {
    if (jsonValue != null) {
      this.setLocalStorage(key, JSON.stringify(jsonValue))
    }
  },
  getJSONLocalStorage(key: string) {
    const value = this.getLocalStorage(key)
    if (value != null) {
      return JSON.parse(value)
    }
  },
  removeLocalStorage(key: string) {
    localStorage.removeItem(key)
  }
}
